<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>

<%-- Creates a table column with the display tag library. Parameters are :
    - colTitleCode : required, the code for the label.
    - colValue : required, the value for the column cells : must be a text value or HTML code
    - colHeaderClass : optional, the column header classes
    - initTableJs : optional, whether to initialize the column headers for the whole table by
              means of javascript. Must be called only once per table, for the last column.
    - colSortable : optional, whether the column should be sortable.
    - colHref : optional, whether to build a link from each column cell content.
    - colParam : optional, in addition to colHref, specifies a parameter for the URL.
 --%>

<%-- Building the column header --%>
<spring:theme var="colTitle" code="${colTitleCode}" />
<spring:theme var="colLongTitle" code="${colTitleCode}" />

<c:set var="colHeader" value='${colTitle}<span class="longTitle"
  style="display:none">${colLongTitle}</span>'/>
<c:set var="theColHeaderClass"
  value="${colHeaderClass} ${empty colLongTitle ? '' : 'titleWithDetails'}"/>

<%-- Adding the Javascript initialization, if required --%>
<c:if test="${initTableJs == true || initTableJs == 'true'}">
  <c:set var="colHeader" value='${colHeader}<script type="text/javascript">$(document).ready(function(){'/>
  <c:set var="colHeader" value='${colHeader}initInfoBoxesOnTableHeader();});</script>'/>
</c:if>

<%-- Creating the column --%>
<c:choose>

  <c:when test="${empty colHref}">
    <display:column title="${colHeader}" sortable="${colSortable}" class="${class}"
        headerClass="${theColHeaderClass}">
      ${colValue}
    </display:column>
  </c:when>

  <c:otherwise>
    <c:choose>

      <c:when test="${empty colParam}">
        <display:column title="${colHeader}" sortable="${colSortable}" href="${colHref}" class="${class}"
          headerClass="${theColHeaderClass}">
          ${colValue}
        </display:column>
      </c:when>

      <c:otherwise>
        <display:column title="${colHeader}" sortable="${colSortable}" href="${colHref}" class="${class}"
          paramId="${colParam}" paramProperty="${colParam}"
          headerClass="${theColHeaderClass}">
          ${colValue}
        </display:column>
      </c:otherwise>
    </c:choose>

  </c:otherwise>
</c:choose>
